<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>收派时间管理</title>
    <!-- 导入jquery核心类库 -->
    <script type="text/javascript" src="../../js/jquery-1.8.3.js"></script>
    <!-- 导入easyui类库 -->
    <link rel="stylesheet" type="text/css" href="../../js/easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="../../js/easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="../../js/easyui/ext/portal.css">
    <link rel="stylesheet" type="text/css" href="../../css/default.css">
    <script type="text/javascript" src="../../js/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../../js/easyui/ext/jquery.portal.js"></script>
    <script type="text/javascript" src="../../js/easyui/ext/jquery.cookie.js"></script>
    <script src="../../js/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            // 先将body隐藏，再显示，不会出现页面刷新效果
            $("body").css({visibility: "visible"});

            // 收派时间管理信息表格
            $('#grid').datagrid({
                iconCls: 'icon-forward',
                fit: true,
                border: false,
                rownumbers: true,
                striped: true,
                pageList: [30, 50, 100],
                pagination: true,
                toolbar: toolbar,
                url: "../../taketime_findAll.action",
                idField: 'id',
                columns: columns
            });
            //添加taketime的
            $("#save").click(function () {
                //校验form表单
                if ($("#takeTimeForm").form("validate")) {
                    $("#takeTimeForm").submit();
                } else {
                    $.messager.alert("警告", "表单中存在非法信息项...", "warning");
                }
            });

        });

        function add() {
            $("#takeTimeWindow").window('open');
        }

        //修改信息
        function edit() {
            var rows = $("#grid").datagrid("getSelections");
            //alert(rows[0].id);
            if (rows.length == 1) {
                $("#takeTimeForm").form("load", rows[0]);
                $("#takeTimeWindow").window("open");
            }
        }

        //作废功能
        function doDelete() {
            var rows = $("#grid").datagrid("getSelections");
            if (rows.length == 0) {
                $.messager.alert("警告", "请至少选择一个进行修改", "warning");
            }else {
               var array = new Array();
                for (var i = 0; i < rows.length; i++) {
                    //将id传递过去
                    array.push(rows[i].id);
                }
                var ids = array.join(",");
                alert(ids);
                window.location.href = "../../takeTime_delBatch.action?ids="+ids;
            }
        }
        //还原功能
        function doRestore() {
            var rows = $("#grid").datagrid("getSelections");
            if (rows.length == 0) {
                $.messager.alert("警告", "请至少选择一个进行修改", "warning");
            }else {
               var array = new Array();
                for (var i = 0; i < rows.length; i++) {
                    //将id传递过去
                    array.push(rows[i].id);
                }
                var ids = array.join(",");
                window.location.href = "../../takeTime_restoreBatch.action?ids="+ids;
            }
        }

        //工具栏
        var toolbar = [{
            id: 'button-add',
            text: '增加',
            iconCls: 'icon-add',
            handler: add
        }, {
            id: 'button-edit',
            text: '修改',
            iconCls: 'icon-edit',
            handler: edit
        }, {
            id: 'button-delete',
            text: '作废',
            iconCls: 'icon-cancel',
            handler: doDelete
        }, {
            id: 'button-delete',
            text: '还原',
            iconCls: 'icon-save',
            handler: doRestore
        }, {
            id: 'button-search',
            text: '查询',
            iconCls: 'icon-search',
            handler: function () {
                // 显示查询窗口
                $("#searchWindow").window('open');
            }
        }];

        // 定义列
        var columns = [[{
            field: 'id',
            checkbox: true,
        }, {
            field: 'name',
            title: '时间名称',
            width: 120,
            align: 'center'
        }, {
            field: 'normalWorkTime',
            title: '平时上班时间',
            width: 120,
            align: 'center'
        }, {
            field: 'normalDutyTime',
            title: '平时休息时间',
            width: 120,
            align: 'center'
        }, {
            field: 'satWorkTime',
            title: '周六上班时间',
            width: 120,
            align: 'center'
        }, {
            field: 'satDutyTime',
            title: '周六休息时间',
            width: 120,
            align: 'center'
        }, {
            field: 'sunWorkTime',
            title: '周日上班时间',
            width: 120,
            align: 'center'
        }, {
            field: 'sunDutyTime',
            title: '周日休息时间',
            width: 120,
            align: 'center'
        }, {
            field: 'status',
            title: '状态',
            width: 120,
            align: 'center',
            formatter: function (value,row,index) {
                if (value == "1") {
                    return "正常";
                }else {
                    return "废除";
                }
            }
        }, {
            field: 'company',
            title: '所属单位',
            width: 120,
            align: 'center'
        }, {
            field: 'operator',
            title: '操作人',
            width: 120,
            align: 'center'
        }, {
            field: 'operatingTime',
            title: '操作时间',
            width: 120,
            align: 'center'
        }, {
            field: 'operatingCompany',
            title: '操作单位',
            width: 120,
            align: 'center'
        }]];
    </script>
</head>
<body class="easyui-layout" style="visibility:hidden;">
<div region="center" border="false">
    <table id="grid"></table>
</div>

<div class="easyui-window" title="对收派时间标准进行添加或者修改" id="takeTimeWindow" collapsible="false" minimizable="false"
     maximizable="false" modal="true" closed="true" style="width:600px;top:50px;left:200px">
    <div region="north" style="height:31px;overflow:hidden;" split="false" border="false">
        <div class="datagrid-toolbar">
            <a id="save" icon="icon-save" href="#" class="easyui-linkbutton" plain="true">保存</a>
        </div>
    </div>

    <div region="center" style="overflow:auto;padding:5px;" border="false">
        <form id="takeTimeForm"
              action="../../takeTime_add.action" method="post">
            <table class="table-edit" width="80%" align="center">
                <tr class="title">
                    <td colspan="2">收派时间标准信息
                        <!--提供隐藏域 装载id -->
                        <input type="hidden" name="id"/>
                    </td>
                </tr>
                <tr>
                    <td>时间名称</td>
                    <td>
                        <input type="text" name="name"
                               class="easyui-validatebox" data-options="required:true"/>
                    </td>
                </tr>
                <tr>
                    <td>平均上班时间</td>
                    <td>
                        <input type="text" name="normalWorkTime"
                               class="easyui-numberbox" required="true"/>
                    </td>
                </tr>
                <tr>
                    <td>平均休息时间</td>
                    <td>
                        <input type="text" name="normalDutyTime" class="easyui-numberbox" required="true"/>
                    </td>
                </tr>
                <tr>
                    <td>周六上班时间</td>
                    <td>
                        <input type="text" name="satWorkTime" class="easyui-numberbox" required="true"/>
                    </td>
                </tr>
                <tr>
                    <td>周六休息时间</td>
                    <td>
                        <input type="text" name="satDutyTime" class="easyui-numberbox" required="true"/>
                    </td>
                </tr>
                <tr>
                    <td>周日上班时间</td>
                    <td>
                        <input type="text" name="sunWorkTime" class="easyui-numberbox" required="true"/>
                    </td>
                </tr>
                <tr>
                    <td>周日休息时间</td>
                    <td>
                        <input type="text" name="sunDutyTime" class="easyui-numberbox" required="true"/>
                    </td>
                </tr>
                <tr>
                    <td>所属单位</td>
                    <td>
                        <input type="text" name="company" class="easyui-validatebox" required="true"/>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>


</body>
</html>
